package com.ss.android.account.e;

import android.animation.Animator;
import android.animation.ObjectAnimator;
import android.util.TypedValue;
import android.view.View;
import android.view.animation.CycleInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;

import com.ss.android.article.browser.R;

public final class AccountAnimatorHelper {
    private static final Interpolator INTERPOLATOR = new DecelerateInterpolator();

    public static Animator createFadeInAnimation(View arg1) {
        return createFadeInAnimation(arg1, null);
    }

    public static Animator createFadeInAnimation(View view, Animator.AnimatorListener animatorListener) {
        return createFadeAnimation(view, 0f, 1f, 260, animatorListener);
    }

    private static Animator createFadeAnimation(View view, float startAlpha, float endAlpha, long duration, Animator.AnimatorListener arg12) {
        float[] values;
        ObjectAnimator objectAnimator = (ObjectAnimator) view.getTag(R.id.cb);
        if (objectAnimator == null) {
            values = new float[2];
            values[0] = startAlpha;
            values[1] = endAlpha;
            objectAnimator = ObjectAnimator.ofFloat(view, "alpha", values);
            view.setTag(R.id.cb, objectAnimator);
        } else {
            objectAnimator.setStartDelay(0);
        }

        objectAnimator.removeAllListeners();
        if (objectAnimator.isRunning()) {
            objectAnimator.cancel();
        }

        if (arg12 != null) {
            objectAnimator.addListener(arg12);
        }

        values = new float[2];
        values[0] = startAlpha;
        values[1] = endAlpha;
        objectAnimator.setFloatValues(values);
        objectAnimator.setInterpolator(INTERPOLATOR);
        objectAnimator.setDuration(duration);
        return objectAnimator;
    }

    public static Animator createTranslationXAnimator(View target, int arg8, int arg9) {
        float[] values;
        ObjectAnimator objectAnimator = (ObjectAnimator) target.getTag(R.id.cc);
        if (objectAnimator == null) {
            values = new float[2];
            values[0] = ((float) arg8);
            values[1] = ((float) arg9);
            objectAnimator = ObjectAnimator.ofFloat(target, "translationX", values);
            target.setTag(R.id.cc, objectAnimator);
        } else {
            ( objectAnimator).setStartDelay(0);
        }

        if (objectAnimator.isRunning()) {
            objectAnimator.cancel();
            objectAnimator.removeAllListeners();
        }

        values = new float[2];
        values[0] = ((float) arg8);
        values[1] = ((float) arg9);
        objectAnimator.setFloatValues(values);
        objectAnimator.setInterpolator(INTERPOLATOR);
        objectAnimator.setDuration(260);
        return ((Animator) objectAnimator);
    }

    public static Animator createFastFadeInAnimation(View arg7) {
        return createFadeAnimation(arg7, 0f, 1f, 100, null);
    }

    public static Animator createTranslationYAnimation(View target, int startY, int endY) {
        float[] v1;
        int v3 = R.id.cd;
        int v6 = 2;
        Object v0 = target.getTag(v3);
        if (v0 == null) {
            v1 = new float[v6];
            v1[0] = ((float) startY);
            v1[1] = ((float) endY);
            v0 = ObjectAnimator.ofFloat(target, "translationY", v1);
            target.setTag(v3, v0);
        } else {
            ((ObjectAnimator) v0).setStartDelay(0);
        }

        if (((ObjectAnimator) v0).isRunning()) {
            ((ObjectAnimator) v0).cancel();
            ((ObjectAnimator) v0).removeAllListeners();
        }

        v1 = new float[v6];
        v1[0] = ((float) startY);
        v1[1] = ((float) endY);
        ((ObjectAnimator) v0).setFloatValues(v1);
        ((ObjectAnimator) v0).setInterpolator(INTERPOLATOR);
        ((ObjectAnimator) v0).setDuration(260);
        return ((Animator) v0);
    }

    public static Animator createFadeOutAnimation(View arg7) {
        return createFadeAnimation(arg7, 1f, 0f, 260, null);
    }

    public static Animator createTranslationXAnimator(View view) {
        ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(view, "translationX",
                new float[]{0f, ((float) (-(((int) TypedValue.applyDimension(1, 5f, view.getResources().getDisplayMetrics())))))});
        objectAnimator.setInterpolator(new CycleInterpolator(5f));
        objectAnimator.setDuration(600);
        return objectAnimator;
    }

    public static void clearAnimation(View view) {
        if (view.getTag() != null
                && ((Animator) view.getTag()).isRunning()) {
            ((Animator) view.getTag()).removeAllListeners();
            ((Animator) view.getTag()).cancel();
        }
    }
}

